import type { ModalProps } from 'antd';
import { Modal } from 'antd';

/**
 * 图片预览
 */
interface Props extends ModalProps {
  previewImage: string;
  previewTitle?: string;
}

export const UploaderPreview: React.FC<Props> = (props) => {
  const { previewImage, previewTitle = 'preview', ...rest } = props;

  return (
    <Modal
      {...rest}
      open={true}
      footer={null}
      styles={{ body: { margin: '0 auto', textAlign: 'center' } }}>
      {previewImage ? (
        <img
          alt={previewTitle}
          style={{ maxWidth: '100%' }}
          src={previewImage}
        />
      ) : null}
    </Modal>
  );
};
